module IdObject (IdObjectClass, getId, getParam, getParamNum, toList, remove, get) where

class IdObjectClass a where
--	empty :: a
        getId :: a -> Int
        getParam :: Int -> a -> String
        getParamNum :: a -> Int
        toList :: a -> [String]

-- zwraca liste bez obiektu z danym id -
remove :: (IdObjectClass a) => Int -> [a] -> [a]
remove i [] = []
remove i [f] | i == (getId f)       = []
             | otherwise            = [f]
remove i (f:fs) | i == (getId f)    = fs
                | otherwise         = [f] ++ (remove i fs)

-- zwraca obiekt o danym id
get :: (IdObjectClass a) => Int -> [a] -> Maybe a
get i [] = Nothing
get i [f]	| i == (getId f)	= Just f
		| otherwise		= Nothing
get i (f:fs)	| i == (getId f)	= Just f
		| otherwise		= get i fs

